﻿using System;
using System.Text;
using System.Collections;
using System.Xml;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Resources;
using System.Reflection;
using System.Globalization;
using System.Threading;
using UFSoft.UBF.UI.WebControls;
using UFSoft.UBF.UI.Controls;
using UFSoft.UBF.Util.Log;
using UFSoft.UBF.Util.Globalization;

using UFSoft.UBF.UI.IView;
using UFSoft.UBF.UI.Engine;
using UFSoft.UBF.UI.MD.Runtime;
using UFSoft.UBF.UI.ActionProcess;
using UFSoft.UBF.UI.WebControls.ClientCallBack;
using UFIDA.U9.UI.PDHelper;
using System.Collections.Generic;
using MF.HSD.StdUnitCostBP.Proxy;



/***********************************************************************************************
 * Form ID: 
 * UIFactory Auto Generator 
 ***********************************************************************************************/
namespace MF.HSD.MFHSDStdUnitCostUIModel
{
    public partial class MFHSDStdUnitCostUIFormWebPart
    {
        #region Custome eventBind
	
		 
				//BtnClose_Click...
		private void BtnClose_Click_Extend(object sender, EventArgs  e)
		{

			this.CloseDialog(false);
		}	
		 
				//BtnOk_Click...
		private void BtnOk_Click_Extend(object sender, EventArgs  e)
		{
			this.Model.ClearErrorMessage();
            if (string.IsNullOrEmpty(this.Model.MFHSDStdUnitCostUI.FocusedRecord.CostField_Code))
            {
				throw new Exception("请选择成本域！");
            }
            try
            {
				GetOutPutQtyItemListProxy proxy = new GetOutPutQtyItemListProxy();
				//取到上月
				DateTime dt = DateTime.Now.AddMonths(-1);
				proxy.DisPlayName = dt.Year + "-" + dt.Month.ToString("#00");
				proxy.CostField = this.Model.MFHSDStdUnitCostUI.FocusedRecord.CostField_Code;
				proxy.OrgCode = PDContext.Current.OrgRef.CodeColumn;
				List<string> itemList = proxy.Do();
				//创建定额成本
				CreateStdUnitCostProxy createProxy = new CreateStdUnitCostProxy();
				createProxy.Item = itemList;
				createProxy.DisPlayName = dt.Year + "-" + dt.Month.ToString("#00"); 
				createProxy.OrgCode = PDContext.Current.OrgRef.CodeColumn;
				string result =createProxy.Do();
			}
			catch(Exception ex)
            {
				throw new Exception(ex.Message);
            }
		

			this.CloseDialog(false);
		}

		
            
            

		#region 自定义数据初始化加载和数据收集
		private void OnLoadData_Extend(object sender)
		{
			if (this.Model.MFHSDStdUnitCostUI.FocusedRecord == null)
				this.Model.MFHSDStdUnitCostUI.AddNewUIRecord();
			OnLoadData_DefaultImpl(sender);
		}
		private void OnDataCollect_Extend(object sender)
		{	
			OnDataCollect_DefaultImpl(sender);
		}
		#endregion  

        #region 自己扩展 Extended Event handler 
		public void AfterOnLoad()
		{

		}

        public void AfterCreateChildControls()
        {


		
        }
        
        public void AfterEventBind()
        {
        }
        
		public void BeforeUIModelBinding()
		{

		}

		public void AfterUIModelBinding()
		{


		}


        #endregion
		
        #endregion
		
    }
}